gltexture: Make release() use download_texture()
authorBenjamin Otte <otte@redhat.com>
Sun, 12 Sep 2021 03:11:58 +0000 (05:11 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 12 Sep 2021 03:22:21 +0000 (05:22 +0200)
1. It avoids Cairo, and in particular conversion to Cairo.

2. Keeping a texture allows easy chaining in the vfuncs.

3. Using a texture means releasing will work for HDR formats
   too, once we add them.

gdk/gdkgltexture.c

index 9b5aa8686647d226483d463b2deb9cec6fb312d1..ef95c4604b200756ae327a6217e5ce898f9ed94d 100644 (file)
@@ -216,24 +216,10 @@ gdk_gl_texture_get_id (GdkGLTexture *self)
 void
 gdk_gl_texture_release (GdkGLTexture *self)
 {
-  GdkTexture *texture = GDK_TEXTURE (self);
-  GBytes *bytes;
-  guchar *data;
-  gsize stride;
-
   g_return_if_fail (GDK_IS_GL_TEXTURE (self));
   g_return_if_fail (self->saved == NULL);
 
-  stride = texture->width * 4;
-  data = malloc (stride * texture->height);
-  gdk_texture_download (texture, data, stride);
-  bytes = g_bytes_new_take (data, stride * texture->height);
-  self->saved = gdk_memory_texture_new (texture->width,
-                                        texture->height,
-                                        GDK_MEMORY_DEFAULT,
-                                        bytes,
-                                        stride);
-  g_bytes_unref (bytes);
+  self->saved = gdk_texture_download_texture (GDK_TEXTURE (self));
 
   if (self->destroy)
     {